Repository navigation
Reduce GCS QPS on ArrayRecordReader open via ReadLast. - #212
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test_992624347
branch
4 times, most recently
from
October 5, 2026 20:10
1c4bdee to
88b11c1
Compare
copybara-service
Bot
force-pushed
the
test_992624347
branch
from
October 13, 2026 23:46
88b11c1 to
492f8fa
Compare
Previously, opening a `gs://` ArrayRecord shard issued 3 separate GCS HTTP GET requests (5 when `index_storage_option` is `offloaded`): 1. An unbounded GET at offset 0 during `GcsReader` construction solely to obtain the object size (and then aborted mid-stream). 2. A GET via `reader->NewReader(size - 64KB)` to read the Riegeli postscript. 3. A GET via `reader->NewReader(footer_offset)` to read the ArrayRecord footer (and additional GETs in `OffloadedChunkOffset::operator[]` when `index_storage_option` is `offloaded`). Open `riegeli::GcsReader` with `google::cloud::storage::ReadLast(1 MiB)` (using a per-reader `google::cloud::storage::Client` instance to avoid cross-thread `libcurl` handle pool contention and `Curl_peer` refcount data races) so the initial HTTP GET retrieves the total object size (`Content-Range`) and prefetches the last 1 MiB of the shard. In `ArrayRecordReaderBase::Initialize()`, pull the prefetched tail into `reader`'s buffer (resetting the cursor to `limit()` so `available() == 0` on close) and read the postscript and footer (including offloaded chunk index lookups in `OffloadedChunkOffset::operator[]`) directly from `reader`'s buffered tail via `ReadChunk` when `footer_offset >= reader->start_pos()`, without spawning subordinate `NewReader` HTTP streams. Real-GCS integration benchmarks show 3.0×–5.0× fewer HTTP GETs on open (23.0× fewer on shards < 1 MiB), 2.0×–3.0× fewer TLS handshakes on open, 2.2×–4.7× faster shard initialization, and 1.13×–1.65× higher bulk read throughput with zero data races. PiperOrigin-RevId: 992624347
copybara-service
Bot
force-pushed
the
test_992624347
branch
from
October 14, 2026 00:22
492f8fa to
3250036
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reduce GCS QPS on ArrayRecordReader open via ReadLast.
Previously, opening a
gs://ArrayRecord shard issued 3 separate GCS HTTP GETrequests (5 when
index_storage_optionisoffloaded):GcsReaderconstruction solely to obtainthe object size (and then aborted mid-stream).
reader->NewReader(size - 64KB)to read the Riegeli postscript.reader->NewReader(footer_offset)to read the ArrayRecord footer(and additional GETs in
OffloadedChunkOffset::operator[]whenindex_storage_optionisoffloaded).Open
riegeli::GcsReaderwithgoogle::cloud::storage::ReadLast(1 MiB)(usinga per-reader
google::cloud::storage::Clientinstance to avoid cross-threadlibcurlhandle pool contention andCurl_peerrefcount data races) so theinitial HTTP GET retrieves the total object size (
Content-Range) andprefetches the last 1 MiB of the shard. In
ArrayRecordReaderBase::Initialize(),pull the prefetched tail into
reader's buffer (resetting the cursor tolimit()soavailable() == 0on close) and read the postscript and footer(including offloaded chunk index lookups in
OffloadedChunkOffset::operator[])directly from
reader's buffered tail viaReadChunkwhenfooter_offset >= reader->start_pos(), without spawning subordinateNewReaderHTTP streams.Real-GCS integration benchmarks show 3.0×–5.0× fewer HTTP GETs on open (23.0× fewer on shards < 1 MiB), 2.0×–3.0× fewer TLS handshakes on open, 2.2×–4.7× faster shard initialization, and 1.13×–1.65× higher bulk read throughput with zero data races.